package com.study.design.proxy.base;

/**
 * 代理类
 */
public class Proxy implements Subject {
    //要代理那个实现类
    private Subject subject = null;

    public Proxy() {
        //默认被代理者
        this.subject = new Proxy();
    }

    public Proxy(Subject subject) {
        this.subject = subject;

    }

    @Override
    public void request() {
        this.before();
        this.subject.request();
        this.after();
    }
    private void before(){
        System.out.println("before");
    }
    private void after(){
        System.out.println("after");
    }
}
